﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using Library;
using Microsoft.Reporting.WinForms;

namespace QLKH.View.report
{
    public partial class ReportlichSuDHKH : Form
    {
        public ReportlichSuDHKH()
        {
            InitializeComponent();
            this.Height = Screen.PrimaryScreen.WorkingArea.Height; //ConfigForm.height;
            this.Width = Screen.PrimaryScreen.WorkingArea.Width;//configForm.width
        }

        private void ReportlichSuDHKH_Load(object sender, EventArgs e)
        {
            this.reportViewerlichsudh.RefreshReport();

            clKhachhang clkh = new clKhachhang();
            AutoCompleteStringCollection dskh = new AutoCompleteStringCollection();

            DataTable dtds = clkh.getautocomplete(0, 0);
            if (dtds != null && dtds.Rows.Count > 0)
            {
                foreach (DataRow row in dtds.Rows)
                {
                    dskh.Add(row["maCu"].ToString());
                }
            }

            txtmakh.AutoCompleteMode = AutoCompleteMode.SuggestAppend;
            txtmakh.AutoCompleteSource = AutoCompleteSource.CustomSource;
            txtmakh.AutoCompleteCustomSource = dskh;
        }

        private void button1_Click(object sender, EventArgs e)
        {
            string makh = txtmakh.Text.Trim();
            clDH CQcp = new clDH();
            DataTable dt = CQcp.LichSuDongHoKH(makh);
            ReportDataSource rpcq = new ReportDataSource();
            rpcq.Name = "DataSetLichSuDHKH";
            rpcq.Value = dt;

            this.reportViewerlichsudh.Reset();
            this.reportViewerlichsudh.LocalReport.ReportEmbeddedResource = "QLKH.View.report.BaoCaoLichSuDH.rdlc";
            this.reportViewerlichsudh.LocalReport.DataSources.Clear();
            this.reportViewerlichsudh.LocalReport.DataSources.Add(rpcq);

            this.reportViewerlichsudh.RefreshReport();
            //this.reportViewerCQphi.ZoomPercent = 100;
            this.reportViewerlichsudh.SetDisplayMode(DisplayMode.PrintLayout);
            this.reportViewerlichsudh.ZoomMode = ZoomMode.Percent;
            this.reportViewerlichsudh.ZoomPercent = 100;
        }

        private void btquit_Click(object sender, EventArgs e)
        {
            this.Close();
        }
    }
}
